﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:AppsListControl="clr-namespace:Coding4Fun.AppsListControl">

	<AppsListControl:Strings x:Key="Strings" />

	<Style TargetType="AppsListControl:PublisherAppsControl">
		<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" />
		<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="AppsListControl:PublisherAppsControl">
					<Grid Background="Transparent">
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="Common">
								<VisualState x:Name="Error">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ErrorView">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="listBox">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Collapsed</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Loading">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LoadingView">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="listBox">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Collapsed</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Normal"/>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="Dummy" Stroke="{TemplateBinding Background}" StrokeThickness="0"/>
						<ListBox x:Name="AppsList" ItemsSource="{Binding Apps}" >
							<ListBox.ItemTemplate>
								<DataTemplate>
                                    <Grid Margin="0,0,0,4" Width="450" Background="{Binding Stroke, ElementName=Dummy}">
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="95"/>
											<ColumnDefinition Width="1*" />
										</Grid.ColumnDefinitions>

										<Rectangle Fill="{StaticResource PhoneAccentBrush}" Width="75" Height="75" Margin="0,0,20,10" />
										<Image Source="{Binding PrimaryImageUrl}" Margin="0,0,20,10" VerticalAlignment="Center" HorizontalAlignment="Center" />
										<StackPanel Grid.Column="1">
											<TextBlock Text="{Binding Title}" FontWeight="Bold" FontSize="22"/>
											<AppsListControl:RatingControl IsEnabled="False" Max="5" Total="{Binding UserRatingCount}" Score="{Binding AverageUserRating}" />
											<TextBlock FontSize="18" Text="{Binding DisplayPrice}" />
										</StackPanel>
									</Grid>
								</DataTemplate>
							</ListBox.ItemTemplate>
						</ListBox>

						<StackPanel x:Name="LoadingView" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
							<TextBlock TextWrapping="Wrap" Text="{Binding DisplayStrings.LoadingMessage, Source={StaticResource Strings}}" FontWeight="Black"/>
							<ProgressBar Margin="0,0,0,6" Height="5" IsIndeterminate="True"/>
						</StackPanel>

						<StackPanel x:Name="ErrorView" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed">
							<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding DisplayStrings.ErrorMessage, Source={StaticResource Strings}}" FontStyle="Italic"/>
						</StackPanel>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="AppsListControl:RatingControl">
		<Setter Property="UseIndicators" Value="false" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="AppsListControl:RatingControl">
					<StackPanel Orientation="Horizontal">
						<ContentControl HorizontalAlignment="Left" Content="{TemplateBinding Content}"/>
						<TextBlock HorizontalAlignment="Left" FontSize="14" x:Name="Indicators" Text="{Binding DisplayStrings.RatingLabel, Source={StaticResource Strings}}" Margin="10,0,0,0"/>
					</StackPanel>
				</ControlTemplate>

			</Setter.Value>
		</Setter>
	</Style>
    
	<Style TargetType="AppsListControl:RatingButton">
		<Setter Property="IsEnabled" Value="true" />
		<Setter Property="IsChecked" Value="false" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="AppsListControl:RatingButton">
					<Grid Opacity="0.5" x:Name="grid">
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="FocusStates">
								<VisualState x:Name="Focused"/>
								<VisualState x:Name="Unfocused"/>
							</VisualStateGroup>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Disabled">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value=".5"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Normal">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="MouseOver">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Pressed"/>
							</VisualStateGroup>
							<VisualStateGroup x:Name="CheckStates">
								<VisualState x:Name="Indeterminate">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathUnchecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathChecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathIndeterminate" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Checked">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathUnchecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathChecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathIndeterminate" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Unchecked">
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathMouseOver" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathUnchecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathChecked" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="pathIndeterminate" Storyboard.TargetProperty="(UIElement.Opacity)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<Grid Width="24" Height="23" x:Name="pathUnchecked" Opacity="0">
							<Path Width="24" Height="23" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 24,10.2671L 15.26,10.2048L 12.5,1.91182L 9.74,10.2048L 1,10.2671L 8.03423,15.4546L 5.39261,23.7861L 12.5,18.6992L 19.6074,23.7861L 16.9658,15.4546L 24,10.2671 Z "/>
						</Grid>
						<Grid Width="24" Height="23" x:Name="pathChecked" Opacity="0">
							<Path Width="24" Height="23" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="Blue"  Data="F1 M 24,10.2671L 15.26,10.2048L 12.5,1.91182L 9.74,10.2048L 1,10.2671L 8.03423,15.4546L 5.39261,23.7861L 12.5,18.6992L 19.6074,23.7861L 16.9658,15.4546L 24,10.2671 Z "/>
						</Grid>
						<Grid Width="24" Height="23" x:Name="pathIndeterminate" Opacity="0">
							<Path Width="24" Height="23" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FF230FD2" Data="M 12.6963,1.56285L 15.4563,9.85585L 24.1963,9.91809L 17.1621,15.1057L 19.8037,23.4371L 12.6963,18.3503M 1.19631,9.91809L 9.93631,9.85585L 12.6963,1.56285L 15.4563,9.85585L 24.1963,9.91809L 17.1621,15.1057L 19.8037,23.4371L 12.6963,18.3503L 5.58892,23.4371L 8.23053,15.1057L 1.19631,9.91809 Z "/>
						</Grid>
						<Grid Width="24" Height="23" x:Name="pathMouseOver" Opacity="0">
							<Path Width="24" Height="23" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="Red" Data="F1 M 24,10.2671L 15.26,10.2048L 12.5,1.91182L 9.74,10.2048L 1,10.2671L 8.03423,15.4546L 5.39261,23.7861L 12.5,18.6992L 19.6074,23.7861L 16.9658,15.4546L 24,10.2671 Z "/>
						</Grid>
					</Grid>
				</ControlTemplate>
                
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>